package com.bckj.freshnow.cart.controller;

import com.bckj.freshnow.cart.domain.qry.CartItemListQryExe;
import com.bckj.freshnow.cart.model.CartItemQuery;
import com.bckj.freshnow.cart.model.CartItemRequest;
import com.bckj.freshnow.cart.model.CartItemResponse;
import com.bckj.freshnow.cart.model.CartItemVO;
import com.bckj.freshnow.cart.service.CartItemService;

import org.springframework.web.bind.annotation.*;

import lombok.RequiredArgsConstructor;
import java.util.List;


/**
 * 购物车商品表(CartItem)表控制层
 *
 * @author makejava
 * @since 2025-04-28 15:27:50
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("")
public class CartItemController {
    /**
     * 服务
     */
	private final CartItemService cartItemService;
	private final CartItemListQryExe cartItemListQryExe;
	
    /**
	 * 购物车列表
	 *
	 * @param query req
	 * @return list
	 */
	@GetMapping("list")
	public List<CartItemVO> list(CartItemQuery query) {
		return cartItemListQryExe.query(query);
	}

	/**
	 * 增加
	 *
	 * @param request req
	 * @return boolean
	 */
	@PostMapping
	public CartItemResponse save(@RequestBody CartItemRequest request) {
		return cartItemService.save(request);
	}

	/**
	 * 修改
	 *
	 * @param request req
	 * @return boolean
	 */
	@PutMapping
	public boolean update(@RequestBody CartItemRequest request) {
		return cartItemService.update(request);
	}

	/**
	 * 移除
	 *
	 * @param id id
	 * @return boolean
	 */
	@DeleteMapping("{id}")
	public boolean remove(@PathVariable Long id) {
		return cartItemService.remove(id);
	}

}

